// departmentService.js
import request from '@/utils/request'

const baseUri = '/depart'

const departmentService = {
  list(searchMap) {
    return request({
      url: `${baseUri}/list`,
      method: 'post',
      data:searchMap
    });
  },

  find(id) {
    return request({
      url: `${baseUri}/find`,
      method: 'get',
      params: { id }
    });
  },

  findAll() {
    return request({
      url: `${baseUri}/findAll`,
      method: 'get'
    });
  },

  update(id,depart) {

    //判断是否有ID，没有就是新增
    if(id===null || id===''){
      return this.add(depart)
    }
    return request({
      url: `${baseUri}/update`,
      method: 'post',
      data: depart // 将部门对象作为请求体传递
    });
  },
  
  add(depart) {
    return request({
      url: `${baseUri}/add`,
      method: 'post',
      data: depart
    });
  },


  remove(id) {
    return request({
      url: `${baseUri}/delete`,
      method: 'get',
      params: { id }
    });
  },

  batchRemove(batchDeleteDto) {
    return request({
      url: `${baseUri}/batchRemove`,
      method: 'post',
      data: batchDeleteDto
    });
  }
};

export default departmentService;